import {router} from '@/router'

export function gotoUrl (_type_id,_link) {
	uni.showToast({
		title: '暂停使用',
		icon:'error'
	})
	
	return
	switch (_type_id){
		case '9999':
			// #ifdef MP
			this.$u.toast('小程序不支持')
			// #endif
			// #ifdef H5
			window.location.href = _link
			// #endif
			// #ifdef APP-NVUE
			this.$u.toast('开发中')
			// #endif
			break;
		case '4':
			router.push({name:'goods/list',params:{cid:_link}})
			break;
		case '3':
			router.push({name:'goods/list',params:{cid:_link}})
			break;
		case '2':
			router.push({name:'goods/list',params:{cid:_link}})
			break;
		default:
			router.push({name:'goods/details',params:{id:_link}})
			break;
	}
	//router.push({name:'article/view',params:{type:_type}})
}

export function gotoUrlByRow (row) {
	if(!row){
		return false
	}
	
	if (!row.link){
		// 未设置跳转
		return false
	}
	if (row.type_id < 1){
		return
	}
	if (row.type_id == 9999){
		// #ifdef H5
		window.open(row.link)
		// #endif
		return
	}
	let json = {}
	try{
		json = JSON.parse(row.link);
	}catch(e){
		//TODO handle the exception
	}
	if (typeof json != 'object'){
		uni.showToast({
			title: '参数解析失败',
			icon:'error'
		})
		
		return
	}
	router.push(json)
}